<html>

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 
  <link rel="stylesheet" title="Default" href="http://acm.math.spbu.ru/~sk1/colorer/my.css">

  <script src="http://acm.math.spbu.ru/~sk1/colorer/highlight.js"></script>
  <script src="http://acm.math.spbu.ru/~sk1/colorer/cpp.js"></script>
  <script>hljs.initHighlightingOnLoad();</script>
</head>

<body>

<pre><code>
/**
 * Author: Sergey Kopeliovich (Burunduk30@gmail.com)
 * Created: 2011.11.24
 */

#include &lt;cstdio&gt;
#include &lt;cstring&gt;
#include &lt;cassert&gt;

#define forn(i, n) for (int i = 0; i &lt; (int)(n); i++)
#define Fill(a, x) memset(a, x, sizeof(a))

template &lt;class T&gt; inline void relaxMin( T &a, T b ) { a = a &lt; b ? a : b; }
template &lt;class T&gt; inline void relaxMax( T &a, T b ) { a = a &gt; b ? a : b; }

const int maxC = 32;

typedef unsigned int uint;

uint d, tmp;
int L, a, c[3];
uint f[maxC][maxC][maxC][maxC][2]; // f[i, c0, c1, c2, carry] = minimum Sum

int main()
{
  #define NAME "binary"
  assert(freopen(NAME ".in", "r", stdin));
  assert(freopen(NAME ".out", "w", stdout));

  forn(i, 3)
  {
    int len = 0;
    scanf("%d", &a);
    while (a)
      c[i] += a & 1, a /= 2, len++;
    relaxMax(L, len);
  }
  Fill(f, -1);
  f[0][0][0][0][0] = 0;
  forn(i, L)
    forn(c0, c[0] + 1)
      forn(c1, c[1] + 1)
        forn(c2, c[2] + 1)
          forn(carry, 2)
            if ((tmp = f[i][c0][c1][c2][carry]) != (uint)(-1))
              forn(a, 2)
                forn(b, 2)
                  d = a ^ b ^ carry, relaxMin(f[i + 1][c0 + a][c1 + b][c2 + d][a + b + carry &gt;= 2], tmp + (d &lt;&lt; i));
  printf("%d\n", f[L][c[0]][c[1]][c[2]][0]);
  return 0;
}

</code></pre>

</body>
</html>

<font style="visibility:hidden">
